<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表白墙</title>
</head>
<body>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .contaion {
            width: 600px;
            margin: 0 auto;
        }
        h1{
            text-align: center;
            padding: 20px 0;
        }
        p {
            text-align: center;
            font-size: 16px;
            color: #666;
            padding: 5px;
        }
        .row {
            padding: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 30px;
        }
        .row span {
            width: 65px;
            font-size: 14px;
        }
        .submit {
            margin: 100px;
            width: 200px;
            height: 30px;
            background-color: orange;
            border: none;
        }
        .submit:active {
            background-color: #666;
        }
    </style>

    <div class="container">
        
        <h1>表白墙</h1>
        <p>输入后提交，会显示在墙上</p>
        <div class="row">
            <span>谁：</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <span>对谁：</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <span>说：</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <input type="button" class="submit" id="button" value="提交">
        </div>
        
        <script>
            button.onclick = function() {
                let edits = document.querySelectorAll(".edit");
                let who = edits[0].value;
                let toWho = edits[1].value;
                let sayWhat = edits[2].value;
                if(who == '' || toWho=='' || sayWhat== '') {
                    return;
                }
                let message = (who + "对" + toWho + "说：" + sayWhat);
                let newDiv = document.createElement("div");
                newDiv.className = "row";
                newDiv.innerHTML = (message);
                let container = document.querySelector(".container");
                container.appendChild(newDiv);
                edits[0].value = "";
                edits[1].value = '';
                edits[2].value='';
            }
        </script>
    </div>
</body>
</html>